#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;

int position (int a[], const int size,int num)
{
		for(int i=0;i<size;i++)
		{
					if(a[i]==num)
					{
					return num=i;
					}
		}
		cout<<"mas don't have this value";
		return -1;

}

void sort (int a[], const int size,int num)
{	
	int x=0; int b=num;
	for(int j=0;j<b;j++)
	{
		for(int i=1;i<b;i++)
		{ 
			if(a[i-1]<a[i])
			{
				x=a[i-1];
			a[i-1]=a[i];
			a[i]=x;
			
			}
		
		}
	}
	
	for(int j=b;j<size;j++)
	{
		for(int i=b+2;i<size;i++)
		{ 
			if(a[i-1]>a[i])
			{
			x=a[i-1];
			a[i-1]=a[i];
			a[i]=x;
			}
			
		}
	}
	
}

void main()
{	
	srand(time(NULL));
	const int size=20;
	int a[size];
	for(int i=0;i<size;i++)
	{		a[i]=i;
			cout<<a[i]<<" ";
			if(a[i]<10)
			{
			cout<<" ";
			}
	}
	cout<<"\n";
	int num=rand()%20+1;
	cout<<"random value"<<num<<"\n";
	num=position(a,size,num);
	cout<<"position of value"<<num<<"\n";
	if(num==-1)
	{
		return;
	}
	sort(a,size,num);
	cout<<"masiv after sort"<<"\n";
	for(int i=0;i<size;i++)
	{		
			cout<<a[i]<<" ";
			if(a[i]<10)
			{
			cout<<" ";
			}
	}
	cout<<"\n";
	}